home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Found / FWODExce / FWSOMEnv.h < prev   
Encoding:
Text File  |  1996-09-17  |  2.6 KB  |  104 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWSOMEnv.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWSOMENV_H
  11. #define FWSOMENV_H
  12.  
  13. #ifndef FWENVDEF_H
  14. #include "FWEnvDef.h"
  15. #endif
  16.  
  17. #ifndef FWEXCLIB_H
  18. #include "FWExcLib.h"
  19. #endif
  20.  
  21. #include <som.xh>
  22.  
  23. //========================================================================================
  24. // CLASS FW_SOMEnvironment
  25. //
  26. //    This class is used instead of Environment *.  It creates a stack-local Environment
  27. // (thereby being threadsafe) and constructs/destructs it.  It overloads "operator->()"
  28. // to provide access to the fields of the underlying Environment.  It also contains 
  29. // "operator Environment* ()" so that it can be passed to SOM methods
  30. //
  31. //    Usage:
  32. //
  33. //        void foo(FW_SOMThing *aSOMThing)
  34. //        {
  35. //            FW_SOMEnvironment ev;
  36. //            aSOMThing->KerSplashMethod(ev);
  37. //        }
  38. //========================================================================================
  39.  
  40.  
  41.  
  42. class FW_SOMEnvironment
  43. {
  44. public:
  45. //    FW_DECLARE_AUTO(FW_SOMEnvironment)
  46.  
  47.     FW_SOMEnvironment();
  48.     ~FW_SOMEnvironment();
  49.  
  50.     Environment* operator->();
  51.     operator Environment*();
  52.  
  53. private:
  54.     Environment fev;
  55. };
  56.  
  57.  
  58. //----------------------------------------------------------------------------------------
  59. //    FW_SOMEnvironment::FW_SOMEnvironment
  60. //----------------------------------------------------------------------------------------
  61.  
  62. inline FW_SOMEnvironment::FW_SOMEnvironment()
  63. {
  64. //    SOM_InitEnvironment(&fev);
  65.     FW_PrimitiveSetMemory(&fev, sizeof(Environment), 0);
  66. //    FW_END_CONSTRUCTOR
  67. }
  68.  
  69.  
  70. //----------------------------------------------------------------------------------------
  71. //    FW_SOMEnvironment::~FW_SOMEnvironment
  72. //----------------------------------------------------------------------------------------
  73.  
  74. inline FW_SOMEnvironment::~FW_SOMEnvironment()
  75. {
  76. //    FW_START_DESTRUCTOR
  77. //    SOM_UninitEnvironment(&fev);
  78. }
  79.  
  80.  
  81. //----------------------------------------------------------------------------------------
  82. //    FW_SOMEnvironment::operator->
  83. //----------------------------------------------------------------------------------------
  84.  
  85. inline Environment* FW_SOMEnvironment::operator->()
  86. {
  87.     return &fev;
  88. }
  89.  
  90.  
  91. //----------------------------------------------------------------------------------------
  92. //    FW_SOMEnvironment::~FW_SOMEnvironment
  93. //----------------------------------------------------------------------------------------
  94.  
  95. inline FW_SOMEnvironment::operator Environment*()
  96. {
  97.     return &fev;
  98. }
  99.  
  100.  
  101. #endif
  102.  
  103.  
  104.